Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
encoding-sniffer
Advanced tools
Implementation of the HTML encoding sniffer algo, with stream support
An implementation of the HTML encoding sniffer algo, with stream support.
This module wraps around iconv-lite to make decoding buffers and streams incredibly easy.
<?xml encoding="...">
npm install encoding-sniffer
import { DecodeStream, getEncoding, decodeBuffer } from "encoding-sniffer";
/**
* All functions accept an optional options object.
*
* Available options are (with default values):
*/
const options = {
/**
* The maximum number of bytes to sniff. Defaults to `1024`.
*/
maxBytes: 1024,
/**
* The encoding specified by the user. If set, this will only be overridden
* by a Byte Order Mark (BOM).
*/
userEncoding: undefined,
/**
* The encoding specified by the transport layer. If set, this will only be
* overridden by a Byte Order Mark (BOM) or the user encoding.
*/
transportLayerEncodingLabel: undefined,
/**
* The default encoding to use, if no encoding can be detected.
*
* Defaults to `"windows-1252"`.
*/
defaultEncoding: "windows-1252",
};
// Use the `DecodeStream` transform stream to automatically decode
// the contents of a stream as they are read
const decodeStream = new DecodeStream(options);
// Or, use the `getEncoding` function to detect the encoding of a buffer
const encoding = getEncoding(buffer, options);
// Use the `decodeBuffer` function to decode the contents of a buffer
const decodedBuffer = decodeBuffer(buffer, options);
This project is licensed under the MIT License. See the LICENSE file for more information.
FAQs
Implementation of the HTML encoding sniffer algo, with stream support
The npm package encoding-sniffer receives a total of 1,041,778 weekly downloads. As such, encoding-sniffer popularity was classified as popular.
We found that encoding-sniffer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.